

function getUserInfo(url){
    $.ajax({
        type:"get",
        url:url,
        success:function(result){
            if(result.code==200 && result.data!=null){
                $(".left .card h3").html(result.data.userName);
                $(".left .card a").attr("href",result.data.githubUrl);
            }
        },
        error:function(error){
            if(error!=null && error.status==401){
                alert("用户未登录, 请先登录");
                location.href = "login.html";
            }
        }
    });
}
function logout(){
    $.ajax({
        type:"post",
        url:"/user/logout",
        success:function(){
            location.href = "login.html";
        }
        
    });
}
// 获取当前url参数的公共方法    
function getUrlValue(key){
    // ex:?id=1&v=2
    var params = location.search;
    if(params.length>1){
        // ex:id=1&v=2
        params = location.search.substring(1);
        var paramArr = params.split("&");
        for(var i=0;i<paramArr.length;i++){
            var kv = paramArr[i].split("=");
            if(kv[0]==key){
                // 是我要查询的参数
                return kv[1];
            }
        }
    }
    return "";
}